<template>
    <div id="app">
        <!-- <middle /> -->
        <!-- <foote /> -->
        <router-view />
    </div>
</template>
<script>
export default {
    name: 'App',
    data() {
        return {
           
        }
    },
    components: {

    },
    created() {
        this.checkIsGray()
    },
    mounted(){
        this.checkLevel()
    },
    methods: {

        /**
         * 检查是否多级平台 1为单机 ，2为多级
         * @DateTime 2020-08-11T15:40:53+0800
         * @qiu_m
         * @return   {[type]}                 [description]
         */
        checkLevel() {
            //在页面刷新时将vuex里的信息保存到sessionStorage里
            window.addEventListener("beforeunload", () => {
                sessionStorage.setItem("storeInof", JSON.stringify(this.$store.state));
            });
            //在页面加载时读取sessionStorage里的状态信息
            if (sessionStorage.getItem("storeInof")) {
                this.$store.replaceState(
                    Object.assign({},
                        this.$store.state,
                        JSON.parse(sessionStorage.getItem("storeInof"))
                    )
                );
            }
        },
        //查看页面是否置灰
        checkIsGray() {
            let success = res => {
                if (res.data.status === true) {
                    document.getElementsByTagName("body")[0].classList.add("is-gray");
                } else {
                    document.getElementsByTagName("body")[0].classList.remove("is-gray");
                }
            };
            this.$ajax({
                url: "api/setting/gray",
                method: "get",
                params: {},
                func: {
                    success: success
                }
            });
        }
    }

};
</script>
<style lang="scss">
.is-gray {
    -webkit-filter: grayscale(100%);
    -moz-filter: grayscale(100%);
    -ms-filter: grayscale(100%);
    -o-filter: grayscale(100%);
    filter: grayscale(100%);
    filter: gray;
}
</style>